
#include <stdio.h>
#include <limits.h>
#include "graph.h"

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)<(b)?(b):(a))

void PrintStats(Graph *g)
{
	int numVerts;
	int numEdges;
	int minDegree;
	int maxDegree;
	int totDegree;
	int degree;
	int row,col;

	numVerts = g->size;
	numEdges = 0;
	minDegree = INT_MAX;
	maxDegree = 0;
	totDegree = 0;

	for(row=0; row<numVerts; row++)
	{
		degree = 0;
		for(col=0; col<numVerts; col++)
		{
			if(GraphGetAdj(g,row,col))
			{
				degree++;
			}
		}
		totDegree += degree;
		minDegree = MIN(minDegree, degree);
		maxDegree = MAX(maxDegree, degree);

	}
	numEdges = totDegree/2;

	GraphPrint(g);
	printf("\n");
	printf("Number of vertices = %d\n", numVerts);
	printf("Number of edges    = %d\n", numEdges);
	printf("Minimum degree     = %d\n", minDegree);
	printf("Maximum degree     = %d\n", maxDegree);
	printf("Average degree     = %f\n", (float)totDegree/(float)numVerts);

	return;
}


